<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>docker上安装与使用fastdfs | Hexo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="1.docker拉取镜像1docker pull morunchang&#x2F;fastdfs  2. 运行tracker1docker run -d --name tracker --net&#x3D;host morunchang&#x2F;fastdfs sh tracker.sh  3. 运行storage12345docker run -d --name storage --net&#x3D;host -e TRACKER_">
<meta property="og:type" content="article">
<meta property="og:title" content="docker上安装与使用fastdfs">
<meta property="og:url" content="http://yoursite.com/2020/07/19/docker%E4%B8%8B%E5%AE%89%E8%A3%85fastdfs/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="1.docker拉取镜像1docker pull morunchang&#x2F;fastdfs  2. 运行tracker1docker run -d --name tracker --net&#x3D;host morunchang&#x2F;fastdfs sh tracker.sh  3. 运行storage12345docker run -d --name storage --net&#x3D;host -e TRACKER_">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="c:%5CUsers%5Claoma%5CAppData%5CRoaming%5CTypora%5Ctypora-user-images%5Cimage-20200719154313392.png">
<meta property="article:published_time" content="2020-07-19T13:21:07.000Z">
<meta property="article:modified_time" content="2020-07-20T13:35:25.766Z">
<meta property="article:author" content="John Doe">
<meta property="article:tag" content="docker">
<meta property="article:tag" content="fastdfs">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="c:%5CUsers%5Claoma%5CAppData%5CRoaming%5CTypora%5Ctypora-user-images%5Cimage-20200719154313392.png">
  
    <link rel="alternate" href="/atom.xml" title="Hexo" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/css/style.css">

<meta name="generator" content="Hexo 4.2.1"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Hexo</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-docker下安装fastdfs" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2020/07/19/docker%E4%B8%8B%E5%AE%89%E8%A3%85fastdfs/" class="article-date">
  <time datetime="2020-07-19T13:21:07.000Z" itemprop="datePublished">2020-07-19</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/docker/">docker</a>►<a class="article-category-link" href="/categories/docker/fastdfs/">fastdfs</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      docker上安装与使用fastdfs
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="1-docker拉取镜像"><a href="#1-docker拉取镜像" class="headerlink" title="1.docker拉取镜像"></a>1.docker拉取镜像</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull morunchang/fastdfs</span><br></pre></td></tr></table></figure>

<h3 id="2-运行tracker"><a href="#2-运行tracker" class="headerlink" title="2. 运行tracker"></a>2. 运行tracker</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -d --name tracker --net=host morunchang/fastdfs sh tracker.sh</span><br></pre></td></tr></table></figure>

<h3 id="3-运行storage"><a href="#3-运行storage" class="headerlink" title="3. 运行storage"></a>3. 运行storage</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">docker run -d --name storage --net=host -e TRACKER_IP=172.30.32.1:22122 -e GROUP_NAME=group1 morunchang/fastdfs sh storage.sh</span><br><span class="line"></span><br><span class="line">docker run -d --name storage --net=host -e TRACKER_IP=192.168.5.137:22122 -e GROUP_NAME=group1 morunchang/fastdfs sh storage.sh</span><br><span class="line"></span><br><span class="line">docker run -d --name storage --net=host -e TRACKER_IP=172.30.39.172:22122 -e GROUP_NAME=group1 morunchang/fastdfs sh storage.sh</span><br></pre></td></tr></table></figure>

<ul>
<li>使用的网络模式是-net=host,127.0.0.1是宿主机的IP</li>
<li>group1是组名，即storage的组</li>
<li>如果想要增加新的storage服务器，再次运行该命令，注意更换组名</li>
</ul>
<h3 id="4-设置容器开机启动"><a href="#4-设置容器开机启动" class="headerlink" title="4. 设置容器开机启动"></a>4. 设置容器开机启动</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker update --restart=always tracker</span><br><span class="line">docker update --restart=always storage</span><br></pre></td></tr></table></figure>

<h3 id="5-进入docker中的storage容器中"><a href="#5-进入docker中的storage容器中" class="headerlink" title="5.进入docker中的storage容器中"></a>5.进入docker中的storage容器中</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker exec -it storage /bin/bash</span><br></pre></td></tr></table></figure>

<ul>
<li>前面安装tracker与storage时候已经安装了nginx</li>
</ul>
<h3 id="6-查看nginx的配置"><a href="#6-查看nginx的配置" class="headerlink" title="6. 查看nginx的配置"></a>6. 查看nginx的配置</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd /etc/nginx/conf</span><br><span class="line">vi nginx.conf</span><br></pre></td></tr></table></figure>

<p><img src="C:%5CUsers%5Claoma%5CAppData%5CRoaming%5CTypora%5Ctypora-user-images%5Cimage-20200719154313392.png" alt="image-20200719154313392"></p>
<p>上图配置如下：</p>
<figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">location</span> <span class="regexp">~ /M00</span>&#123;</span><br><span class="line">	<span class="attribute">root</span> /data/fast_data/data;</span><br><span class="line">	ngx_fastdfs_module;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>增加禁止缓存：</p>
<figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">add_header</span> Cache-Control <span class="literal">no</span>-store;</span><br></pre></td></tr></table></figure>

<p>退出容器：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">exit</span><br></pre></td></tr></table></figure>

<p>重启storage容器：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker restart storage</span><br></pre></td></tr></table></figure>

<p>查看启动容器  <code>docker ps</code></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">199b787fc342        morunchang/fastdfs   "sh storage.sh"          33 minutes ago      Up 33 minutes        storage</span><br><span class="line">6a3c6a3d57e8        morunchang/fastdfs   "sh tracker.sh"          About an hour ago   Up About an hour     tracker</span><br></pre></td></tr></table></figure>



<h3 id="7-查看storage的配置"><a href="#7-查看storage的配置" class="headerlink" title="7. 查看storage的配置"></a>7. 查看storage的配置</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">进入storage容器</span></span><br><span class="line">docker exec -it storage /bin/bash</span><br><span class="line"><span class="meta">#</span><span class="bash">进入fdfs目录</span></span><br><span class="line">cd /etc/fdfs</span><br><span class="line"><span class="meta">#</span><span class="bash">进入配置文件</span></span><br><span class="line">vi storage.conf</span><br></pre></td></tr></table></figure>


      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2020/07/19/docker%E4%B8%8B%E5%AE%89%E8%A3%85fastdfs/" data-id="ckct4u2wk00006gv14vre3pim" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/docker/" rel="tag">docker</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/fastdfs/" rel="tag">fastdfs</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2020/07/21/win10%E5%BC%80%E5%90%AFhyper-v%E5%90%8E%EF%BC%8C%E7%B3%BB%E7%BB%9F%E4%BF%9D%E7%95%99%E7%9A%84%E7%AB%AF%E5%8F%A3%E5%AF%BC%E8%87%B4%E7%AB%AF%E5%8F%A3%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          win10开启hyper-v后，系统保留的端口导致端口无法使用
        
      </div>
    </a>
  
  
    <a href="/2020/07/15/win10%E4%B8%8B%E7%9A%84wsl1%E5%8D%87%E7%BA%A7%E4%B8%BAwsl2/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">win10下的wsl1升级为wsl2</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/docker/">docker</a><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/docker/fastdfs/">fastdfs</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/docker/mysql/">mysql</a></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/idea/">idea</a><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/idea/github/">github</a></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/java/">java</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/win10/">win10</a><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/win10/hyper-v/">hyper-v</a></li></ul></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/MySQL/" rel="tag">MySQL</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/canal/" rel="tag">canal</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/docker/" rel="tag">docker</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/fastdfs/" rel="tag">fastdfs</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/github/" rel="tag">github</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gui/" rel="tag">gui</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hyper-v/" rel="tag">hyper-v</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/idea/" rel="tag">idea</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/" rel="tag">java</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/log/" rel="tag">log</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/lua/" rel="tag">lua</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nginx/" rel="tag">nginx</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/openresty/" rel="tag">openresty</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/port/" rel="tag">port</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/redis/" rel="tag">redis</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ubuntu/" rel="tag">ubuntu</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/win10/" rel="tag">win10</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/windows10/" rel="tag">windows10</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wsl/" rel="tag">wsl</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wsl1/" rel="tag">wsl1</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wsl2/" rel="tag">wsl2</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/MySQL/" style="font-size: 12.5px;">MySQL</a> <a href="/tags/canal/" style="font-size: 12.5px;">canal</a> <a href="/tags/docker/" style="font-size: 17.5px;">docker</a> <a href="/tags/fastdfs/" style="font-size: 10px;">fastdfs</a> <a href="/tags/github/" style="font-size: 10px;">github</a> <a href="/tags/gui/" style="font-size: 10px;">gui</a> <a href="/tags/hyper-v/" style="font-size: 10px;">hyper-v</a> <a href="/tags/idea/" style="font-size: 10px;">idea</a> <a href="/tags/java/" style="font-size: 15px;">java</a> <a href="/tags/log/" style="font-size: 10px;">log</a> <a href="/tags/lua/" style="font-size: 12.5px;">lua</a> <a href="/tags/nginx/" style="font-size: 10px;">nginx</a> <a href="/tags/openresty/" style="font-size: 15px;">openresty</a> <a href="/tags/port/" style="font-size: 10px;">port</a> <a href="/tags/redis/" style="font-size: 10px;">redis</a> <a href="/tags/ubuntu/" style="font-size: 20px;">ubuntu</a> <a href="/tags/win10/" style="font-size: 12.5px;">win10</a> <a href="/tags/windows10/" style="font-size: 10px;">windows10</a> <a href="/tags/wsl/" style="font-size: 10px;">wsl</a> <a href="/tags/wsl1/" style="font-size: 10px;">wsl1</a> <a href="/tags/wsl2/" style="font-size: 12.5px;">wsl2</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/08/">August 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/07/">July 2020</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2020/08/11/Mysql-Host-is-blocked-because-of-many-connection-errors/">Mysql Host is blocked because of many connection errors</a>
          </li>
        
          <li>
            <a href="/2020/08/08/canal%E5%90%8C%E6%AD%A5MySQL%E6%95%B0%E6%8D%AE%E9%85%8D%E7%BD%AE/">canal同步MySQL数据配置</a>
          </li>
        
          <li>
            <a href="/2020/08/03/docker%E4%B8%8Acanal%E5%AE%B9%E5%99%A8%E7%9A%84%E5%AE%89%E8%A3%85/">docker上canal容器的安装</a>
          </li>
        
          <li>
            <a href="/2020/08/03/MySQL%E5%BC%80%E5%90%AFbinlog%E6%97%A5%E5%BF%97%E6%A8%A1%E5%BC%8F/">MySQL开启binlog日志模式</a>
          </li>
        
          <li>
            <a href="/2020/08/01/openresty%E4%BD%BF%E7%94%A8lua%E8%84%9A%E6%9C%AC%E5%AE%9E%E7%8E%B0%E5%B9%BF%E5%91%8A%E7%BC%93%E5%AD%98/">openresty使用lua脚本实现广告缓存.md</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2020 John Doe<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css">

  
<script src="/fancybox/jquery.fancybox.pack.js"></script>




<script src="/js/script.js"></script>




  </div>
</body>
</html>